﻿using Com.JunCaiSoft.Permission.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Permission.EntityMap
{
    public class AuthorizeMap : IEntityTypeConfiguration<Authorize>
    {
        public void Configure(EntityTypeBuilder<Authorize> builder)
        {
            builder.ToTable("Authorize");

            builder.HasKey(k => k.id);

            builder.HasMany(h => h.children)
                .WithOne(h => h.parent)
                .HasForeignKey(k => k.parentId)
                .OnDelete(DeleteBehavior.ClientSetNull);
        }
    }
}
